define([
  'weui',
  'cityData'
], function (weui, cityData) {
  /**
   * 城市选择器
   * @param {*} title 标题
   * @param {*} depth 深度[1-3]
   * @param {*} callback 回调
   */
  function showCityPicker(title, depth, callback) {
    depth = depth > 3 ? 3 : depth;
    let defValue = null;
    if (depth == 1) {
      defValue = [110000];
    } else if (depth == 2) {
      defValue = [110000, 110000];
    } else {
      defValue = [110000, 110000, 110101];
    }

    weui.picker(cityData.getData(), {
      defaultValue: defValue,
      depth: depth,
      onChange: function (result) {
        if (callback)
          callback.onChange(result);
      },
      onConfirm: function (result) {
        if (callback)
          callback.onConfirm(result)
      },
      title: title
    });
  }

  return {
    showCityPicker: showCityPicker
  }

});